import { createRouter, createWebHashHistory } from "vue-router";
import MyIndex from "../views/MyIndex.vue";

const routes = [
    { path: "/", redirect: "/myindex/detail" },
    {
        path: "/myindex",
        name: "myindex",
        component: MyIndex,
        children: [
            {
                path: "detail",
                component: () => import("../views/IndexDetail/IndexDetail.vue"),
            },
            {
                path: "classify",
                component: () => import("../views/MyClassify/MyClassify.vue"),
            },
            {
                path: "shoppingcart",
                component: () => import("../views/ShoppingCart/ShoppingCart.vue"),
            },
            {
                path: "mypage",
                component: () => import("../views/MyPage/MyPage.vue"),
            },
        ],
    },
    {
        path: "/loginregister",
        name: "loginregister",
        component: () => import("../views/LoginRegister/LoginRegister.vue"),
        children: [
            { path: "/loginregister", redirect: "/loginregister/login" },
            {
                path: "login",
                component: () => import("../views/LoginRegister/MyLogin.vue"),
            },
            {
                path: "register",
                component: () => import("../views/LoginRegister/MyRegister.vue"),
            },
        ],
    },
    {
        path: "/commoditydetails/:id",
        name: "commoditydetails",
        component: () => import("@/views/CommodityDetails/CommodityDetails.vue"),
    },
    {
        path: "/search",
        name: "search",
        component: () => import("@/views/MySearch/MySearch.vue"),
    },
    {
        path: "/clear",
        name: "clear",
        component: () => import("@/views/MyClear/MyClear.vue"),
    },
    {
        path: "/order",
        name: "order",
        component: () => import("@/views/MyOrder/MyOrder.vue"),
    },
    {
        path: "/address",
        name: "address",
        component: () => import("@/views/MyAddress/MyAddress.vue"),
    },
    {
        path: "/addaddress",
        name: "addaddress",
        component: () => import("@/views/MyAddress/AddAddress.vue"),
    },
    {
        path: "/personaldata",
        name: "personaldata",
        component: () => import("@/views/MyPage/PersonalData.vue"),
    },
    {
        path: "/mycollect",
        name: "mycollect",
        component: () => import("@/views/MyPage/MyCollect.vue"),
    },
    {
        path: "/notreceived",
        name: "notreceived",
        component: () => import("@/views/MyPage/NotReceived.vue"),
    },
    {
        path: "/toreceived",
        name: "toreceived",
        component: () => import("@/views/MyPage/ToReceived.vue"),
    },
];

const router = createRouter({
    history: createWebHashHistory(),
    routes,
});

export default router;
